﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// CheckFlow 的摘要说明
/// </summary>
public class CheckFlow
{
	public CheckFlow()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    /// <summary>
    /// 检测某流程的当前审核人是否为当前用户
    /// </summary>
    /// <param name="userName">用户名</param>
    /// <param name="FlowID">流程编号</param>
    /// <returns></returns>
    public Boolean CheckIsMyFlow(string userName, string FlowID)
    {
        string tabYear = FlowID.Substring(4, 4);
        string sqlString = "select count(*) from LC" + tabYear + " as LC inner join LCBZ" + tabYear + " as LCBZ on LC.TRUEFLOWID=LCBZ.TRUEFLOWID and LC.CURRENTSTEP=LCBZ.SEQ";
        sqlString += " where LC.STATUS='0'and LCBZ.OPERATORID='" + userName + "' and LC.TRUEFLOWID='"+FlowID+"'";
        DBOperation DBO = new DBOperation();
        int count = Convert.ToInt32(DBO.ExcuteScalar(sqlString));
        if (count == 1)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    /// <summary>
    /// 自动发送跟审核相关的信息
    /// </summary>
    /// <param name="trueFlowID"></param>
    /// <param name="fromUserName"></param>
    /// <param name="toUserName"></param>
    /// <param name="content"></param>
    /// <returns></returns>
    public Boolean SendCheckMessage(string trueFlowID, string fromUserName, string toUserName,string content)
    {

        string title = "您有新的文件需要审批了！";
        string addcontent = "您有新的文件需要审批了！流程号:" + trueFlowID + "。"+ content;
        messages sendMS = new messages();
        sendMS.FromUserName = fromUserName;
        sendMS.ToUserName = toUserName;
        sendMS.TrueFlowID = trueFlowID;
        sendMS.Title = title;
        sendMS.Content = addcontent;
        if (sendMS.SendCheckDataMessage())
        {
            return true;
        }
        return false;
    }
}
